﻿@inherits AdminCompontentBase

<DefaultSheetDialog Value="Visible" ValueChanged=UpdateVisible Title="@T("Edit Staff")">
    <MForm Model="Staff" EnableValidation EnableI18n>
        <AutoHeight Overflow AutoClass="mt-6">
            <HeaderContent>
                <div class="d-flex">
                    <div class="mx-auto text-center">
                        <UploadAvatar @bind-Value="Staff.Avatar" WhenFileChangeUpload />
                        <SNameTextField @bind-Value="Staff.DisplayName" style="width:212px;" Placeholder="@T("Give him a nickname!")" />
                    </div>
                </div>
            </HeaderContent>
            <AutoHeightContent>
                <div class="subtitle2">@T("BasicInformation")</div>
                <div Class="mt-4">
                    <ButtonGroup @bind-Value="Staff.Gender" TValue="GenderTypes" />
                </div>
                <MRow Class="mt-6">
                    <MCol>
                        <STextField @bind-Value="Staff.Name" Label="@T("Name")" />
                    </MCol>
                    <MCol>
                        <STextField @bind-Value="Staff.PhoneNumber" Required Label="@T("PhoneNumber")" />
                    </MCol>
                </MRow>
                <MRow Class="mt-1">
                    <MCol>
                        <STextField @bind-Value="Staff.Email" Label="@T("Email")" />
                    </MCol>
                    <MCol>
                        <EnumSelect @bind-Value=Staff.StaffType TValue="StaffTypes" Clearable=false Label="@T("StaffType")" />
                    </MCol>
                </MRow>
                <MRow Class="mt-1">
                    <MCol>
                        <TeamRoleSelect @bind-Value="Staff.Teams" Excludes="StaffDetail.TeamIds" />
                    </MCol>
                    <MCol>
                        <STextField @bind-Value="Staff.IdCard" Label="@T("IdCard")" />
                    </MCol>
                </MRow>
                <MRow Class="mt-1">
                    <MCol>
                        <STextField @bind-Value="Staff.Address.Address" Label="@T("Address")" />
                    </MCol>
                    <MCol>
                        <DepartmenCascader @bind-Value="Staff.DepartmentId" />
                    </MCol>
                </MRow>
                <MRow Class="mt-1">
                    <MCol>
                        <STextField @bind-Value="Staff.JobNumber" Required Disabled Label="@T("JobNumber")" />
                    </MCol>
                    <MCol>
                        <PositionSelect @bind-Value="Staff.Position" />
                    </MCol>
                </MRow>

                <Authorization Avatars=StaffDetail.ThirdPartyIdpAvatars />
                <Record Creator="@StaffDetail.Creator" CreationTime="@StaffDetail.CreationTime" Modifier="@StaffDetail.Modifier" ModificationTime="@StaffDetail.ModificationTime" />
            </AutoHeightContent>
            <FooterContent>
                <div class="d-flex mt-6">
                    <EnableSwitch @bind-Value="Staff.Enabled" DisabledLabel="@T("Freeze")" />
                    <MSpacer></MSpacer>
                    <SButton Medium Class="mr-6" Text Color="error" OnClick=OpenRemoveStaffDialog>@T("Delete")</SButton>
                    <SButton Medium OnClick="async () => await UpdateStaffAsync(context)">@T("Save")</SButton>
                </div>
            </FooterContent>
            </AutoHeight>
    </MForm>
</DefaultSheetDialog>
